#include <stdio.h>
int IsLeapYear(int year)
{
    if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))
    {
        return 1;
    }
    else
        return 0;
}
int main()
{
    int year = 0, month = 0;
    while (~scanf("%d%d", &year, &month))
    {
        int ret = IsLeapYear(year);
        if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
        {
            printf("31\n");
        }
        else if (month == 2)
        {
            if (ret == 1)
                printf("29\n");
            else
                printf("28\n");
        }
        else
            printf("30\n");
    }
    return 0;
}